/**
 * 地图类
 * Author:  suyuyi
 * Date:    2017-4-15
 */
cc.Class({
    extends: cc.Component,

    properties: {

    _width:  2000,
    _height: 1000,
    _boxSize:  50,
    
    },
    drawLeftDanger: function(){
        this._bg.rect(this.mapStartX, this.mapStartY, 250, this._height);
        this._bg.fillColor = cc.color(100,0,0,255);
        this._bg.fill();
    },
    drawRightDanger: function(){
        this._bg.rect(this._width - 250 , this.mapStartY, 250, this._height);
        this._bg.fillColor = cc.color(100,0,0,255);
        this._bg.fill();
    },
    onLoad : function(){
        
        this.mapStartX = 0;
        this.mapStartY = 0;
        //var bgNode = new cc.Node();
        //bgNode.parent = this;
        //cc.log("Node Position X: " + this.node.x);
        this._bg = this.node.getComponent(cc.Graphics);
        
       
        this._bg.rect(this.mapStartX, this.mapStartY, this._width, this._height);
        this._bg.fillColor = cc.color(38,36,53,255);
        this._bg.fill();

        this.drawRightDanger();
        this.drawLeftDanger();

        var line = this.node.getComponent(cc.Graphics);

        
        //竖线
        for(var x = 0; x <= this._width; x += this._boxSize){
            line.moveTo(this.mapStartX + x, this.mapStartY);
            line.lineTo(this.mapStartX + x, this._height);
            line.strokeColor = cc.color(255,255,255,100);
            line.stroke();
        }
        //横线
        for(var y = 0; y <= this._height; y += this._boxSize){
            if(y == 150 || y == this._height - 150){
                line.strokeColor = cc.color(255,255,255,50);
                line.lineWidth   = 7;
            }
            else{
                line.strokeColor = cc.color(255,255,255,100);
                line.lineWidth   = 1;
            }

            line.moveTo(this.mapStartX, this.mapStartY + y);
            line.lineTo(this._width, this.mapStartY + y);
            line.stroke();
        }
    }
});
